package com.example.liuanlu.myapplication;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.view.View.OnClickListener;

public class MainActivity extends AppCompatActivity implements OnClickListener {

    private String phoneNo;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btn_start = (Button) findViewById(R.id.btn_start);
        btn_start.setOnClickListener(this);

        Button btn_stop = (Button) findViewById(R.id.btn_stop);
        btn_stop.setOnClickListener(this);
    }

    public void onClick(View v) {
        TextView tv = (TextView) findViewById(R.id.textView);
        switch (v.getId()) {
            case R.id.btn_start:
                tv.setText("开始");
                startService(new Intent(this, MyService.class));
                break;
            case R.id.btn_stop:
                tv.setText("停止");
                stopService(new Intent(this, MyService.class));
                break;
        }
    }
}


